/**************************
* @Summary 人类函数的实现
* @Author 20009200303 赵传博
* @Date 2022/3/22
*****************************/

#include "People.h"

People::People(string name, double val):name(move(name)), val(val), avg(0.0), addTimes(1){

}

string People::getName(){
    return this->name;
}

double People::getVal() const {
    return this->val;
}

double People::getAvg() const {
    return this->avg;
}

void People::addVal(double _val) {
    /* 计算新的平均值和总和，addTimes用来记录加了多少个重名的对象 */
    this->avg = (this->val + _val) / ++addTimes;
    this->val += _val;

}

void People::setAvg(double _avg) {
    this->avg = _avg;
}

